import XEUtils from 'xe-utils';
import VXETable from 'vxe-table';
import {commonConstants,getFixedValue} from 'hhlt-core/constants'
import {fixedDatasource as commonFixedDatasource} from 'hhlt-core/constants'
import {dateUtils, objectUtils} from 'hhlt-core/utils'
import {assign} from 'min-dash';

var emsFormatUtils = {
  /**
   * 格式化固定值
   * @param {Object} value
   */
  formatFixedDatasourceOther(value:any, fixedDatasource?:any) {
    
    if (!value) {
      return
    }

    if (value instanceof Object) {

      fixedDatasource = value.column.params.fixedDatasource
      value = value.cellValue
    }

    if (!fixedDatasource) {

      throw "请配置数据源！"
    }
    if (!getFixedValue(fixedDatasource)) {

      throw "配置固定数据源错误！"
    }
    var keys = Object.keys(getFixedValue(fixedDatasource))

    for (var i = 0; i < keys.length; i++) {

      if (((commonFixedDatasource as any)[fixedDatasource] as any)[keys[i]].value === value) {

        return ((commonFixedDatasource as any)[fixedDatasource] as any)[keys[i]].otherInfo;
      }
    }
    return "无效数据"

  }
}

export default emsFormatUtils;
